
# -*- coding: utf-8 -*-
#   f7帮助编辑框
# @Time    ： 2024/5/13  21:55
# @Auther  ： 徐良
# File     :  f7LineEdits.py
from PySide6 import QtWidgets
from PySide6.QtCore import QSize, Qt
from PySide6.QtWidgets import QLineEdit
from mesParts.components.f7HelpPanel import F7HelpPanel


class F7BaseLineEdit(QLineEdit):
    """
    f7帮助编辑框基类
    """
    def __init__(self, pDict=None, parent=None):
        """

        :param pict:
        :param parent:
        """
        super(F7BaseLineEdit, self).__init__(parent)
        if pDict is not None:
            self.dict = pDict

        self.ROB = 0
        self.setMinimumSize(QSize(120, 16777215))

        self.work = None                # 基础系统的对象
        self.valueList = None           # 值列表
        self.retValueList = None        # 返回值的值列表
        self.retTypeList = None         # 返回值的值类型列表
        self.retFieldList = None        # 返回字段名列表

        self.setPlaceholderText('按F7获取帮助')




    def setROB(self, value):
        """
        红蓝字设置
        :param value:
        """
        if self.ROB != value:
            self.ROB = value
            self.setStyleSheet("color: red;") if self.ROB == 1 else self.setStyleSheet("color: rgb(37, 43, 65);")


class F7HeadLineEdit(F7BaseLineEdit):
    """
    用于表头，独立使用，与QDataWidgetMapper配合使用，界面是有浏览和查询界面的
    """

    def __init__(self, pDict=None, parent=None):
        super(F7HeadLineEdit, self).__init__(pDict)

    def keyPressEvent(self, event):
        QtWidgets.QLineEdit.keyPressEvent(self, event)
        if event.key() == Qt.Key_F7:

            dic = {'obj': self, 'work': self.work, 'objectName': self.objectName(),
                   'className': 'F7HeadLineEdit'}

            self.f7panel = F7HelpPanel(self.dict)          # 创建面板对象
            self.f7panel.F7HelpRetSignal.connect(self.onF7ret)
            self.f7panel.show()

    def onF7ret(self, pDict):
        """

        :return:
        """
        print('返回')




class F7HeadSimpleLineEdit(F7BaseLineEdit):
    """
    用于表头，独立的，简易帮助面板
    """

    def __init__(self, work, parent=None):
        super(F7HeadSimpleLineEdit, self).__init__(parent)


#         **************************        表体lineEdit      ************************************

class F7BodyLineEdit(F7BaseLineEdit):
    """
    用于表体，由代理创建，带浏览和查询面板的
    """

    def __init__(self, work, parent=None):
        super(F7BodyLineEdit, self).__init__(parent)
        # self.work = work
        # self.valueList = None
        # self.retValueList = None
        # self.retTypeList = None
        # self.retFieldList = None
        # self.setMinimumSize(QSize(120, 16777215))
        # self.helpPosition = 'Head'
        # self.index = None


class F7BodySimpleLineEdit(F7BaseLineEdit):
    """
    用于表体，由代理创建，简易帮助面板
    """

    def __init__(self, work, parent=None):
        super(F7BodyLineEdit, self).__init__(parent)
        # self.work = work
        # self.valueList = None
        # self.retValueList = None
        # self.retTypeList = None
        # self.retFieldList = None
        # self.setMinimumSize(QSize(120, 16777215))
        # self.helpPosition = 'Head'
        # self.index = None


